#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    int minOperations(vector<int>& nums) {
        if(nums.size()==1){
            return 0;
        }
        int count = 0;
        for(int i = 1;i<nums.size();++i){
            if(nums[i]>nums[i-1]){
                
            }
            else{
                int temp = nums[i];
                nums[i] = nums[i-1]+1;
                count += (nums[i]-temp);
            }
        }
        return count;
    }
};

int main(){
    Solution S;
    vector<int> nums = {1,5,2,4,1};
    cout<<S.minOperations(nums)<<endl;
}